Table of Contents

Open In Colab

Stanford Car Dataset Localization - TF2-Keras version

Author: Suresh Venkatesan

Trained_Models: All the models and history files that are used in the results summary of this notebook can be downloaded from the "Training_Outputs" sub-folder present in this Link

Complete preliminaries

Connect to Google Drive

Install Keras Tuner

Import required libraries

Define directory paths

Dataset - Import, EDA and pre-process

Import dataset

Load annotation files to Pandas Dataframes

Split test_orig_df into test_df and val_df

Get information about train, val and test datasets

Get class distribution

Training Set

Validation Set

Test Set

Define image folder paths

Define Function: Visualize Data

Define Function: Visualize Images from DataFrame

Visualize Data

Training Set

Validation Set

Test Set

Define Batch Data Generators

Define Function: plot_img_transf

Visualize some image transformations

Define base model, target image shape and model batch size

Define pre-processing function

Define augmentations

Verify augmentations

Classes: Define batch generator class

Define Generator Objects

Verify generator objects

Visualize the data from generator objects

Models - Build, Train, Tune

Functions

Define Model Core

Verify Model Core

IoU computation

Define Model_Compile

Define Model_Fit

Define Model_Train

Classes

Define HyperModel Class (For Hyperparameter Tuning)

Set model_core, model_compile, model_train parameters

Launch Tensorboard

Train Model

This section is commented out as the models have already been trained and stored to disk.

LR Finder section - Please ignore

Hyperparameter Tuning - Please ignore

Results Summary

Define Functions

Function: get_model

Function: plot_lc

Function: plot_cm

Function: predict_and_plot_df

Model - 1

Define file paths

Plot learning curves

Reinstantiate train, val and test generators

No augmentation will be done and shuffling will be turned off. 'preprocessing_function' will be set based on the model that's being loaded.

Evaluate model on training and test sets

Predict and plot

Training Set

Test set

Model - 2

Define file paths

Plot learning curves

Reinstantiate train, val and test generators

No augmentation will be done and shuffling will be turned off. 'preprocessing_function' will be set based on the model that's being loaded.

Evaluate model on training and test sets

Predict and plot

Training Set

Test set

Model - 3

Define file paths

Plot learning curves

Reinstantiate train, val and test generators

No augmentation will be done and shuffling will be turned off. 'preprocessing_function' will be set based on the model that's being loaded.

Evaluate model on training and test sets

Predict and plot

Training Set

Test set

Model - 4

Define file paths

Plot learning curves

Reinstantiate train, val and test generators

No augmentation will be done and shuffling will be turned off. 'preprocessing_function' will be set based on the model that's being loaded.

Evaluate model on training and test sets

Predict and plot

Training Set

Test set

Model Ensemble

In this section, an ensemble of the four models defined above is created and performance evaluated on the ensembled model.

Backup